#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pp;
const int N=3e5+10;//最多用n+2*m个坐标
int n,m;
int x,c,l,r;
vector<int>help;//存储待离散化的下标
vector<pp> arr;
vector<pp>xuwen;
int sum[N];

int find(int x)
{
    int l=0,r=help.size()-1,ans=-1;
    while(l<=r)
    {
        int mid=(r-l)/2+l;
        if(help[mid]>=x)
        {
            ans=mid;
            r=mid-1;
        }
        else
        {
            l=mid+1;
        }
    }
    return ans+1;
}
int main()
{
    cin>>n>>m;
    for(int i=0;i<n;i++) 
    {
        cin>>x>>c;
        arr.push_back({x,c});
        help.push_back(x);
    }
    for(int i=0;i<m;i++)
    {
        cin>>l>>r;
        xuwen.push_back({l,r});
        help.push_back(l);
        help.push_back(r);
    }
    sort(help.begin(),help.end());
    help.erase(unique(help.begin(),help.end()),help.end());
    for(auto&ch:arr)
    {
        int temind=find(ch.first);
        sum[temind]+=ch.second;
    }
    for(int i=1;i<=help.size();i++)
    {
        sum[i]=sum[i-1]+sum[i];
    }
    for(auto&ch:xuwen)
    {
        cout<<sum[ch.second]-sum[ch.first-1]<<endl;
    }
    return 0;
}